Only copy over the native output directory once
authorAlex Crichton <alex@alexcrichton.com>
Wed, 23 Jul 2014 16:36:49 +0000 (09:36 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 23 Jul 2014 19:19:02 +0000 (12:19 -0700)
Previously it was copying once per target, not once per package.

src/cargo/ops/cargo_rustc/fingerprint.rs
tests/test_cargo_test.rs

index c72fa7c7372758c7e7f34171f871a90c9376ff27..df17c0d7faab59006f1d0d32879d2018442a5b06 100644 (file)
@@ -47,11 +47,16 @@ pub fn prepare(cx: &mut Context, pkg: &Package,
     // Prepare a job to copy over all old artifacts into their new destination.
     let mut pairs = Vec::new();
     pairs.push((old_fingerprint_loc, new_fingerprint_loc));
+
+    // TODO: this shouldn't explicitly pass false, for more info see
+    //       cargo_rustc::compile_custom
+    if pkg.get_manifest().get_build().len() > 0 {
+        let layout = cx.layout(false);
+        pairs.push((layout.old_native(pkg), layout.native(pkg)));
+    }
+
     for &target in targets.iter() {
         let layout = cx.layout(target.get_profile().is_plugin());
-        if pkg.get_manifest().get_build().len() > 0 {
-            pairs.push((layout.old_native(pkg), layout.native(pkg)));
-        }
         for filename in cx.target_filenames(target).iter() {
             let filename = filename.as_slice();
             pairs.push((layout.old_root().join(filename),
index 16eb46ddaeb832882847525b7856612b140fa419..09936b00b34bc4f7295c6387b1891cad2c355a31 100644 (file)
@@ -559,3 +559,43 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured\n\n\
                        fresh = FRESH,
                        dir = p.root().display()).as_slice()));
 })
+
+test!(test_twice_with_build_cmd {
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+            [package]
+            name = "foo"
+            version = "0.0.1"
+            authors = []
+            build = 'true'
+        "#)
+        .file("src/lib.rs", "
+            #[test]
+            fn foo() {}
+        ");
+
+    assert_that(p.cargo_process("cargo-test"),
+                execs().with_status(0)
+                       .with_stdout(format!("\
+{compiling} foo v0.0.1 (file:{dir})
+
+running 1 test
+test foo ... ok
+
+test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured\n\n\
+                       ",
+                       compiling = COMPILING,
+                       dir = p.root().display()).as_slice()));
+    assert_that(p.process(cargo_dir().join("cargo-test")),
+                execs().with_status(0)
+                       .with_stdout(format!("\
+{fresh} foo v0.0.1 (file:{dir})
+
+running 1 test
+test foo ... ok
+
+test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured\n\n\
+                       ",
+                       fresh = FRESH,
+                       dir = p.root().display()).as_slice()));
+})